/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.z100h.supplychain.core.biz.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.z100h.supplychain.core.EvidenceState;
import com.z100h.supplychain.core.biz.entity.CommonEvidence;
import com.z100h.supplychain.core.biz.mapper.CommonEvidenceMapper;

/**
 * 各种单子凭证Service
 * @author fyh
 * @version 2019-01-03
 */
@Service
@Transactional(readOnly = true)
public class CommonEvidenceService extends CrudService<CommonEvidenceMapper, CommonEvidence> {

	@Autowired
	private CommonEvidenceMapper commonEvidenceMapper;

	@Override
	public CommonEvidence get(String id) {
		return super.get(id);
	}

	@Override
	public List<CommonEvidence> findList(CommonEvidence commonEvidence) {
		return super.findList(commonEvidence);
	}

	/**
	 * 
	 * 查询未完成的出库单
	 * 
	 * @return
	 * @author: Fyh - 1009173473@qq.com 
	 * @date: Created on 2019年5月15日 上午9:44:39
	 */
	public List<CommonEvidence> findUnfinishStockoutEvidenceList() {
		return commonEvidenceMapper.findUnfinishStockoutEvidenceList();
	}

	@Override
	public Page<CommonEvidence> findPage(Page<CommonEvidence> page, CommonEvidence commonEvidence) {
		return super.findPage(page, commonEvidence);
	}

	@Override
	@Transactional(readOnly = false)
	public void save(CommonEvidence commonEvidence) {
		super.save(commonEvidence);
	}

	@Override
	@Transactional(readOnly = false)
	public void delete(CommonEvidence commonEvidence) {
		super.delete(commonEvidence);
	}

	@Transactional(readOnly = false)
	public void updateEvidenceState(String id, int state) {
		commonEvidenceMapper.updateEvidenceState(id, state);
	}

	/**
	 * 
	 * 完成 单据
	 * 
	 * @param id
	 * @param evidenceState
	 * @author: Elvin Zhao - 279152260@qq.com 
	 * @date: Created on 2019年1月5日 上午11:46:00
	 */
	@Transactional(readOnly = false)
	public void finishEvidence(String evidenceId, EvidenceState evidenceState) {
		commonEvidenceMapper.updateEvidenceState(evidenceId, evidenceState.getValue());
	}

	public String findType(String id) {
		return commonEvidenceMapper.findType(id);
	}

}